//
//  ViewController.m
//  CPButtonScrollView
//
//  Created by MorpLCP on 16/5/10.
//  Copyright © 2016年 MorpLCP. All rights reserved.
//

#import "ViewController.h"
#import "CPSpinnerButtonView.h"

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate, CPSpinnerButtonViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    CPSpinnerButtonView *v = [[CPSpinnerButtonView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    v.minGap = 50;  // 设置最小间隙
    v.lineHeight = 3; // 设置线条宽度
    v.selectColor = [UIColor cyanColor]; // 设置选中颜色
    v.unSelectColor = [UIColor blackColor]; // 设置未选中颜色
    v.delegate = self;
    UIView *v1 = [UIView new];
    v1.backgroundColor = [UIColor redColor];
    UIView *v2 = [UIView new];
    v2.backgroundColor = [UIColor blueColor];
    UITableView *v3 = [[UITableView alloc] init];
    v3.delegate = self;
    v3.dataSource = self;
    [v3 registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [v addContentItems:@[v1, v2, v3] Titles:@[@"量化收益", @"今日排行", @"我去你妹"]];
    [self.view addSubview:v];
}

- (void)buttonView:(CPSpinnerButtonView *)buttonView didSelectItem:(NSNumber*)index{
    NSLog(@"%@-----%@", buttonView, index);
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%ld", indexPath.row);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = @"看看";
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
